﻿@model IEnumerable<Forum.ViewModels.ForumPostViewModel>
@{
    ViewBag.Title = "Home Page";
}
<form method="get">
    <input type="text" name="searchterm" placeholder="search" maxlength="240" size="28"/>
</form>
@foreach (var post in Model)
{
    
    <div class="question-summary">
        
       <div id="votes">
           <div>
               <span id="raiting_@post.Id">Rating: @post.Raiting</span>    

            </div>
           <div>
        <a class="up-vote" data-id="@post.Id"></a>
        <a class="down-vote" data-id="@post.Id"></a> 
               </div>  
            </div>
      <span class="title"> <a href="/questions/@post.Id/@post.Title"> @post.Title </a> </span>
        <br />
       Author: @post.Username
    </div>
}
<script>
    $(".up-vote").click(function (e) {
        var id = $(this).attr("data-id");
        $("#raiting_" + id).load("/ForumPosts/voteUp/" + id);
        e.preventDefault();
    })
    $(".down-vote").click(function (e) {
        var id = $(this).attr("data-id");
        $("#raiting_" + id).load("/ForumPosts/voteDown/" + id);

        e.preventDefault();
    })
</script>
